/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package models.dao;

import com.mysql.jdbc.CallableStatement;
import com.mysql.jdbc.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import model.dao.util.*;
import model.pojo.KhachHangDTO;


/**
 *
 * @author User
 */
public class KhachHangDAO {

  
 public int DangNhap(KhachHangDTO khDto){


            int kt = 0;
        try {

                MySqlDataAccessHelper helper=new MySqlDataAccessHelper();
                helper.open();
               Connection connect = (Connection) helper.getConnection();



            String sql = "{call spDangNhap(?,?)}";
            CallableStatement cs = (CallableStatement) connect.prepareCall(sql);
            cs.setString("tenDangNhap", khDto.getTenDangNhap());
            cs.setString("matKhau", khDto.getMatKhau());
            ResultSet rs = cs.executeQuery();
            while (rs.next()) {
                kt = rs.getInt("kt");
            }
            connect.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return kt;

        }

}
